home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr10 / accenter.zip / ACCENTER.S < prev    next >
Text File  |  1993-06-09  |  4KB  |  156 lines

  1. /**************** Foreign-Character Macros **************************
  2.  
  3.   For TSE (The Semware Editor), pre-release version 1.0
  4.  
  5.   Author:  David Mayerovitch
  6.            7 June 1993
  7.  
  8.   Description:
  9.  
  10.   This pair of macros provides a quick and convenient way of entering
  11.   foreign-language and other special characters.
  12.  
  13.   mSelectLanguage() presents a menu of languages or other
  14.   special-character sets for the user to choose from. I have assigned
  15.   this macro to <Alt `>.
  16.  
  17.   mAccenter() enables the entry of the special characters belonging to
  18.   the selected set.  I have assigned this macro to the key <`>. Call
  19.   this the trigger key.
  20.  
  21.   These macros do what you do when writing foreign characters by hand:
  22.   first write the basic letterform, then add the diacritical mark.
  23.  
  24.   Example: If the selected language is French and you want to enter
  25.   the character <é> (e with accent aigu): type the basic character
  26.   <e>, then press the trigger key.  A menu appears:
  27.  
  28.   ┌──────────┐
  29.   │ Aigu  é  │
  30.   │ Grave è  │
  31.   │ Circ  ê  │
  32.   └──────────┘
  33.  
  34.   The hotkeys A, G, and C generate the three possible e-based accented
  35.   characters in French. Press <A> and the <e> just typed will be
  36.   replaced with <é>.
  37.  
  38.   When there is only one possible accented version of the character
  39.   just typed (e.g. ü in German), the macro automatically inserts it
  40.   without presenting a menu.
  41.  
  42.   The macros as presented here offer the following character sets:
  43.   French: à â ç Ç é è ê É î ô û
  44.   German: ä Ä ö ü Ü
  45.   International (German + French): à â ä Ä ç Ç é è ê É î ô ö û ü Ü
  46.   Currency: c/C --> ¢ (cents)  l/L --> £ (pounds)  y/Y --> ¥ (yen)
  47.  
  48.   You may easily edit the macros to provide any substitutions
  49.   you want, arranged in languages or character sets of your
  50.   choice.  Strings as well as single characters may be
  51.   substituted.
  52.  
  53.   If a printable key such as <`> is chosen as the trigger for
  54.   mAccenter(), the Literal() command (assigned to <Ctrl P> in
  55.   the factory configuration of TSE) may be used whenever the
  56.   character itself is required in the text.
  57.  
  58.   Comments and improvements are welcome.
  59.  
  60. ********************************************************************/
  61.  
  62. // global variable:
  63. integer language = 1 // French is default
  64.  
  65. // LANGUAGE SELECTION ROUTINES:
  66.  
  67. menu langMenu()
  68.   history
  69.   "&French"  "&German"   "&International"
  70.   "", , Divide  "&Currency"
  71. end
  72.  
  73. proc mSelectLanguage()
  74.   langMenu()
  75.   language = MenuOption()
  76. end
  77.  
  78. // CHARACTER SUBSTITUTION ROUTINES:
  79.  
  80. proc sub(string newstring)
  81. // replaces current char by newstring, forcing insert.
  82.   DelChar()
  83.   InsertText(newstring,_insert_)
  84. end
  85.  
  86. menu FrenchAMenu()
  87.   "&Grave à", sub('à') "&Circ  â", sub('â')
  88. end
  89.  
  90. menu IntlAMenu()
  91.   "&Grave  à", sub('à')
  92.   "&Circ   â", sub('â') "&Umlaut ä", sub('ä')
  93. end
  94.  
  95. menu IntlOMenu()
  96.   "&Circ   ô", sub('ô') "&Umlaut ö", sub('ö')
  97. end
  98.  
  99. menu IntlUMenu()
  100.   "&Circ   û", sub('û') "&Umlaut ü", sub('ü')
  101. end
  102.  
  103. menu FrenchEMenu()
  104.   "&Aigu é", sub('é') "&Grave è", sub('è') "&Circ ê", sub('ê')
  105. end
  106.  
  107. proc French()
  108.   case Chr(CurrChar())
  109.     when 'a' FrenchAMenu() when 'e' FrenchEMenu()
  110.     when 'E' sub('É') when 'c' sub('ç') when 'C' sub('Ç')
  111.     when 'i' sub('î') when 'o' sub('ô') when 'u' sub('û')
  112.   otherwise Right()
  113.     endcase
  114. end
  115.  
  116. proc German()
  117.   case Chr(CurrChar())
  118.     when 'a' sub('ä') when 'A' sub('Ä') when 'o' sub('ö')
  119.     when 'O' sub('Ö') when 'u' sub('ü') when 'U' sub('Ü')
  120.   otherwise Right()
  121.     endcase
  122. end
  123.  
  124. proc International()
  125.   case Chr(CurrChar())
  126.     when 'e' FrenchEMenu() when 'a' IntlAMenu()
  127.     when 'o' IntlOMenu()  when 'u' IntlUMenu()
  128.     when 'A' sub('Ä') when 'c' sub('ç') when 'C' sub('Ç')
  129.     when 'i' sub('î') when 'E' sub('É') when 'O' sub('Ö')
  130.     when 'U' sub('Ü')
  131.   otherwise Right()
  132.     endcase
  133. end
  134.  
  135. proc Currency()
  136.   case UpCase(Chr(CurrChar()))
  137.     when 'C' sub('¢') // cents
  138.     when 'L' sub('£') // pounds
  139.     when 'Y' sub('¥') // yen
  140.   otherwise Right()
  141.     endcase
  142. end
  143.  
  144. proc mAccenter()
  145.   Left()
  146.   Case language
  147.     when 1 French() when 2 German() when 3 International()
  148.     when 5 Currency()
  149.     endcase
  150. end
  151. <`> mAccenter()
  152. <Alt `> mSelectLanguage()
  153.  
  154. /************************** End of macros **************************/
  155.  
  156.